package com.nf.xiaomi.service.impl;

import com.nf.mvc.file.MultipartFile;
import com.nf.xiaomi.util.MinioUtils;

import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;


public class FileService {
    public static String uploadFile(String bucket,MultipartFile file) {
        InputStream inputStream=null;
        UUID uuid =UUID.randomUUID();
        String fileName=uuid.toString()+"."+file.getOriginalFilename().split("\\.")[1];
        try {
            inputStream = file.getInputStream();
        } catch (IOException e) {
            System.out.println("get InputStream Error :"+e.getMessage());
        }
        System.out.println(MinioUtils.putObjectStream(inputStream, fileName, bucket));
        return fileName;
    }
}
